//axios.defaults.baseURL = 'http://127.0.0.1:8888';

var fh ="";
var cs1 = "";
var cs2 = "";
var 运算符 = "";
function onSsBtn(){
    $.ajax({
        // url:"https://cc6ae273-8888-app.lightly.teamcode.com/getByMingChen?port=8888&dcsId=cc6ae273&token=AlJknEarRW-9vhuljRCOkA",
        url: "http://127.0.0.1:8888/getByMingChen",
    //    url: "http://localhost:8888/jisuanqi",
        type: "get",
        data: {
          mingchen:$("#ssInput").val()
        },
        dataType: "json",
        jsonpCallback:"cb",
        success: function (result) {
            console.log(result)
            const template = $("#zjTemplate").html();
            let boxContent = result;
            for(const i in result){
                const con = result[i];
                const text = template.replace("{{bangdan}}",con.bangdan).replace("{{mingchen}}",con.mingchen).replace("{{zhanji}}",con.zhanji);
                boxContent+=text;
            }
            console.log("boxContent",boxContent);
            $("#box").html(boxContent);
        }
    })
}


function equals1(){
    const op = $("#ssInput").val();
    console.log( "当前公式为：" + op);
    console.log( "当前运算符：" , 运算符);
    const array = op.split(运算符);
    console.log( "当前运算符分割后：" , array);
    $.ajax({
        // url:"https://cc6ae273-8888-app.lightly.teamcode.com/getByMingChen?port=8888&dcsId=cc6ae273&token=AlJknEarRW-9vhuljRCOkA",
       // url: "http://127.0.0.1:8888/getByMingChen",
       url: "http://localhost:8888/jisuanqi",
        type: "get",
        data: {
            cs1: array[0],
            cs2: array[1],
            fh:fh
        },
        dataType: "json",
        jsonpCallback:"cb",
        success: function (result) {
            console.log(result)
           const template = $("#zjTemplate").html();
            let boxContent = result;
            for(const i in result){
                const con = result[i];
                const text = template.replace("{{bangdan}}",con.bangdan).replace("{{mingchen}}",con.mingchen).replace("{{zhanji}}",con.zhanji);
                boxContent+=text;
            }
            // $("#输出").val(result);
            console.log("boxContent",boxContent);
            $("#box").html(boxContent);
        }
    })
}
$.get(
    "http://localhost:8888/getAll",
    function (result) {
        console.log(result)
        const template = $("#zjTemplate").html();
        let boxContent = "";
        for(const i in result){
            const con = result[i];
            const text = template.replace("{{bangdan}}",con.bangdan).replace("{{mingchen}}",con.mingchen).replace("{{zhanji}}",con.zhanji);
            boxContent+=text;
        }
        console.log("boxContent",boxContent);
        $("#box").html(boxContent);
    }
)

    // $.ajax({
    //     type: "get",
    //     url: "http://localhost:8888/getAll",
    //     dataType: "json",
    //     jsonpCallback:"cb",
    //     success: function (result) {
    //             console.log(result)
    //             const template = $("#zjTemplate").html();
    //             let boxContent = "";
    //             for(const i in result){
    //                 const con = result[i];
    //                 const text = template.replace("{{bangdan}}",con.bangdan).replace("{{mingchen}}",con.mingchen).replace("{{zhanji}}",con.zhanji);
    //                 boxContent+=text;
    //             }
    //             console.log("boxContent",boxContent);
    //             $("#box").html(boxContent);
    //     }
    // });

function cb(){
    console.log("cb")
}
//$("#ssInput").val("请输入...")
function pn(val){
    console.log("你按下了：" + val);
    var oldVal = $("#ssInput").val();
    $("#ssInput").val(oldVal + val)
}

function po(val){
    console.log("你按下了：" + val);
    运算符 = "";
    switch(val){

        case "1":
            运算符 ="+";
            break;
        case "2":
            运算符 ="-";
            break;
        case "3":
            运算符 ="*";
            break;
        case "4":
            运算符 ="/";
            break;
    }

    var oldVal = $("#ssInput").val();
    $("#ssInput").val(oldVal + 运算符)
    fh = val;
}


// let xhr = new XMLHttpRequest();
//     xhr.onreadystatechange = event => {
//         console.log(event);
//     }
//     xhr.open('get', 'https://cc6ae273-8888-app.lightly.teamcode.com/getAll?port=8888&dcsId=cc6ae273&token=AlJknEarRW-9vhuljRCOkA');
//     xhr.send();

//     $.ajax({
//         type: "get",
//         url: "https://cc6ae273-8888-app.lightly.teamcode.com/getAll?port=8888&dcsId=cc6ae273&token=AlJknEarRW-9vhuljRCOkA",
//         dataType: 'application/json;charset=UTF-8',
//         success: function (data) {
//         console.log("success")
//         console.log(data.responseText)
//         },
//         error: function (message) {
//         console.log("error")
//         console.log(message.responseText)
//         }
//         });



